from classfile.attribute_info import AttributeInfo


class InnerClassInfo:
    def __init__(self, innerClassInfoIndex, outerClassInfoIndex, innerNameIndex, innerClassAccessFlags):
        self.innerClassInfoIndex = innerClassInfoIndex
        self.outerClassInfoIndex = outerClassInfoIndex
        self.innerNameIndex = innerNameIndex
        self.innerClassAccessFlags = innerClassAccessFlags


class InnerClassesAttribute(AttributeInfo):
    def __init__(self):
        super().__init__()
        self.classes = []

    def readInfo(self, clsReader):
        nameOfClasses = int.from_bytes(clsReader.readU16(), "big")
        for i in range(nameOfClasses):
            self.classes.append(InnerClassInfo(
                int.from_bytes(clsReader.readU16(), "big"),
                int.from_bytes(clsReader.readU16(), "big"),
                int.from_bytes(clsReader.readU16(), "big"),
                int.from_bytes(clsReader.readU16(), "big")))

